<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Add a lexer rule</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parle-rlexer.insertmacro.html">« Parle\RLexer::insertMacro</a></li>
      <li style="float: right;"><a href="parle-rlexer.pushstate.html">Parle\RLexer::pushState »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.parle-rlexer.html">Parle\RLexer</a></li>
    <li>Add a lexer rule</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="parle-rlexer.push" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Parle\RLexer::push</h1>
  <p class="verinfo">(PECL parle &gt;= 0.5.1)</p><p class="refpurpose"><span class="refname">Parle\RLexer::push</span> &mdash; <span class="dc-title">Add a lexer rule</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-parle-rlexer.push-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Parle\RLexer::push</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$id</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>Parle\RLexer::push</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$state</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$id</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$newState</code></span><br>): <span class="type"><span class="type void">void</span></span></div>

  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>Parle\RLexer::push</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$state</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$newState</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   Push a pattern for lexeme recognition.
  </p>
  <p class="para">A &#039;start state&#039; and &#039;exit state&#039; can be specified by using a suitable signature. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-parle-rlexer.push-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">regex</code></dt>

    <dd>

     <p class="para">
      Regular expression used for token matching.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">id</code></dt>

    <dd>

     <p class="para">
      Token id. If the lexer instance is meant to be used standalone, this can be an arbitrary number. If the lexer instance is going to be passed to the parser, it has to be an id returned by <span class="methodname"><a href="parle-rparser.tokenid.html" class="methodname">Parle\RParser::tokenid()</a></span>.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">state</code></dt>

    <dd>

     <p class="para">
      State name. If &#039;*&#039; is used as start state, then the rule is applied to all lexer states.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">newState</code></dt>

     <dd>

      <p class="para">
       New state name, after the rule was applied.
      </p>
      <p class="para">
       If &#039;.&#039; is specified as the exit state, then the lexer state is unchanged when that rule matches. An exit state with &#039;&gt;&#039; before the name means push. Use the signature without id for either continuation or to start matching, when a continuation or recursion is required.
      </p>
      <p class="para">
       If &#039;&lt;&#039; is specified as exit state, it means pop. In that case, the signature containing the id can be used to identify the match. Note that even in the case an id is specified, the rule will finish first when all the previous pushes popped.
      </p>
     </dd>

   
   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-parle-rlexer.push-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。   
  </p>
 </div>



</div></div></div></body></html>